﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KulaTools.Models
{
    public class Email
    {
        public string From { get; set; }
        public string Recipient { get; set; }
        public string BCC { get; set; }

        public string Subject { get; set; }
        public string Body { get; set; }
        public bool IsHtml { get; set; }
        public System.Net.Mail.MailPriority Priority { get; set; }

        public List<EmailAttachment> Attachmanets { get; set; }
      

        public List<string> Errors { get; set; }
        public bool HasErrors
        {
            get
            {
                if (this.Errors != null)
                {
                    return (Errors.Count > 0);
                }
                else
                {
                    return false;
                }
            }
        }


        //Internal methods
        
        /// <summary>
        /// Add a filename to be added as an attachment before sending the email. Errors will be ignored.
        /// </summary>
        /// <param name="localFullPathToFileName"></param>
        public void AddAttachment(string localFullPathToFileName)
        {
            if (this.Attachmanets == null)
                this.Attachmanets = new List<EmailAttachment>();
            this.Attachmanets.Add(new EmailAttachment() { LocalFilePath = localFullPathToFileName });
        }
    }


    public class EmailAttachment
    {
        public string LocalFilePath { get; set; }
    }
}
